package com.company;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;

public class test02 {
    public static void main(String[] args) {
        Collection<Integer> c=new ArrayList<>();
        c.add(123);
        c.add(199);
        c.add(200);
        c.add(200);
        c.add(200);
        System.out.println(c);

       // c.clear();  清空集合
        System.out.println(c.contains(200));
        System.out.println(c.equals(123));
        System.out.println(c.hashCode());
        //System.out.println(c.remove(200));
        System.out.println(c);
        System.out.println(c.isEmpty());
        System.out.println(c.size());
        Object[] os=c.toArray();//集合转换数组
        System.out.println(Arrays.toString(os));



        Collection<Integer> c1=new ArrayList<>();
        c1.add(1);
        c1.add(2);
        c1.add(3);
        System.out.println(c.addAll(c1));
        System.out.println(c.containsAll(c1));
        //System.out.println(c.removeAll(c1)); //移除交集
        //System.out.println(c.retainAll(c1));//保留交集
        System.out.println(c);
        Iterator<Integer> it=c.iterator();
        while (it.hasNext()){
            Integer in=it.next();
            System.out.println(in);
        }
        for (Integer in:c){
            System.out.println(in);
        }


    }
}
